package com.hectopascal.goalance.controller;

import com.hectopascal.goalance.pojo.SystemSetting;
import com.hectopascal.goalance.pojo.dto.ResponseMessage;
import com.hectopascal.goalance.service.Ipml.ISystemSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/settings")
public class SystemSettingController {
    @Autowired
    ISystemSettingService systemSettingService;

    @GetMapping("/getsettings")
    public ResponseMessage<List<SystemSetting>> systemSettingGet() {
        return ResponseMessage.success(systemSettingService.systemSettingGet());
    }

    @PutMapping("/updatesetting")
    public ResponseMessage<String> systemSettingUpdate(@RequestBody SystemSetting systemSetting) {
        int rows=systemSettingService.systemSettingUpdate(systemSetting);
        if(rows!=0) {
            return ResponseMessage.success("更新成功");
        }else{
            return ResponseMessage.fail("更新失败");
        }
    }
}
